<?php 
	
	class skill_mapping_model extends CI_Model {
		
		 var $tblName = "Skill_Mapping";
		 
		function __construct()
		{
			parent::__construct();
		}
		
		function add($record)
		{
			$result=$this->db->insert($this->tblName, $record);
			DB_modification_logs("skill_mapping");
			if($result)
				return true;
			else
				return false;	
		
		}
		function update($record,$id)
		{
			$this->db->where('id',$id);
			$result=$this->db->update($this->tblName, $record);
			DB_modification_logs("skill_mapping");
			if($result)
			{
				return true;
			}
			else
				return false;	
			
			
		}
		function getListingData($GET, $start, $offset = 20)
		{
 			$where = ' WHERE 1=1 ';
			if( isset($GET['skill_id']) && intval($GET['skill_id']) > 0 )
			{
				$where  .= " AND skill_id = ".(int)$GET['skill_id']." ";	
			}
			if( isset($GET['primary_server_id']) && intval($GET['primary_server_id']) > 0 )
			{
				$where  .= " AND primary_server_id = ".(int)$GET['primary_server_id']." ";	
			}
			if( isset($GET['secondary_server_id']) && intval($GET['secondary_server_id']) > 0 )
			{
				$where  .= " AND secondary_server_id = ".(int)$GET['secondary_server_id']." ";	
			}
			
			$LIMIT = "LIMIT $start ,  $offset ";
			$sql = "SELECT SQL_CALC_FOUND_ROWS * FROM " . $this->tblName . " {$where} {$LIMIT} ";
			$results = $this->db->query($sql)->result();	
			$total_record = $this->common_model->get_found_rows();
			
			return array('results' => $results, 'total_record' => $total_record);
		}
		
		function getDetailsbySkill($skill)
		{
		  $sql = "SELECT * FROM " . $this->tblName . " WHERE Skill= "."'".$skill."'";
		  return $this->db->query($sql)->row_array();
		}
		function getDetailbyid($id)
		{
			$sql = "SELECT * FROM " . $this->tblName . " WHERE id= ".$id;
		  return $this->db->query($sql)->row_array();	
		}
		function getSkillbyname($skill) 
		{
			
			$sql = "SELECT * FROM  queue_table where name ="."'".$skill."'" ;
			return $this->db->query($sql)->result();
		}
  }
?>